import collections


class Solution(object):
    def countBalls(self, lowLimit, highLimit):
        max_len = 0
        d = collections.defaultdict(int)

        def convert(num):
            s = str(num)
            ans = 0
            for c in s:
                ans += int(c)
            return ans

        for num in range(lowLimit, highLimit + 1):
            d[convert(num)] += 1
            max_len = max(max_len, d[convert(num)])
        return max_len
